<cfif len(trim(form.newpassword)) IS 0 OR len(trim(form.newusername)) IS 0 OR len(trim(form.fullname)) IS 0 OR len(trim(form.emailaddress)) IS 0>
<div id="messages_error">All fields on this form are required.</div>
<cfelse>
	<cfif NOT form.newpassword IS form.newpassword_confirm>
        <div id="messages_error">The confirmation password and password field did not match.  User could not be added.</div>
    <cfelse>
		<cfinvoke component="cfcs.common.encryption" method="encryptstring" textstring="#form.newpassword#" returnvariable="enc_password">
    
        <cfquery name = "CheckDuplicateUser" datasource="#request.dsn#">
        SELECT * FROM core_admins
        WHERE username = '#form.NewUsername#'
        </cfquery>
        
        <cfif CheckDuplicateUser.recordcount IS 0>
        <cfquery name = "AddUser" datasource="#request.dsn#">
        INSERT INTO core_admins
        (username, pword, userlevel, fullname, emailaddress, userid)
        VALUES
        ('#form.newusername#', '#enc_password#', '#form.userlevel#', '#form.fullname#', '#form.emailaddress#', '0')
        </cfquery>
        <cfset showform = 0>
        <div id="messages">New admin user account has been added.</div>
        
        Your browser will redirect in a few seconds...<br />
        <a href = "index.cfm?c=cpusers">Click here if it does not redirect in 5 seconds</a>
        </p>
        <script language="javascript">
            pageurl = 'index.cfm?c=cpusers';
            setTimeout('delayer(pageurl)', 3000);
        </script>       
        <cfelse>
        <div id="messges_error">Duplicate user detected.  The new user was not added.</div>
        </cfif>
    </cfif>
</cfif>